<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<c:if test="${empty pass}">
    <c:redirect url="book_manager"></c:redirect>
</c:if>
<script type="text/javascript" src = "rsrc/js/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src = "rsrc/js/jquery.validationEngine.js"></script>

<script>
    $(document).ready(function(){
        $('#book_form').validationEngine('attach');
        $('#cancelBookForm').click(function(){           
           $('#book_form').validationEngine('hideAll');
           $('#book_form').validationEngine('detach');
        });
    });
</script>
<div class="separator"></div>
<div id="book_part">
    <c:if test="${!empty book}" >
        <p class="page_label">Add New Book</p>
    </c:if>
    <c:if test="${empty book}" >
        <p class="page_label">Add New Book</p>
    </c:if>
  
    <form id="book_form" action="add_book_action" method="post" >
        <table id="book_form_table">
            <tr>
                <td class="label" align="left">Book Title</td>
                <td align="left"><input type='text' <c:if test="${!empty book}"> value="${book.title}" </c:if> name='bookTitle' id='bookTitle' class="validate[required,custom[onlyLetterSp]] input_text" title=""/>*</td>
            </tr>                    
            <tr>
                <td class="label" align="left">ISBN:</td>
                <td align="left"><input type='text' <c:if test="${!empty book}"> value="${book.isbn}" </c:if> name='isbn' id='isbn' class="validate[required,custom[onlyNumberSp] input_text" title=""/>*</td>
            </tr>
            <tr>
                <td class="label" align="left">Author:</td>
                <td align="left"><input type='text' <c:if test="${!empty book}"> value="${book.author}" </c:if> name='author' id='author' class="validate[required,custom[onlyLetterSp]] input_text" title=""/>*</td>
            </tr>
            <tr>
                <td class="label" align="left">Publisher:</td>
                <td align="left"><input type='text' <c:if test="${!empty book}"> value="${book.publisher}" </c:if> name='publisher' id='publisher' class="validate[required,custom[onlyLetterSp]] input_text" title=""/>*</td>
            </tr>
            <tr>
                <td class="label" align="left">Category:</td>
                <td align="left"><input type='text' <c:if test="${!empty book}"> value="${book.category}" </c:if> name='category' id='category' class="validate[required,custom[onlyLetterSp]] input_text" title=""/>*</td>
            </tr>
            <tr>
                <td class="label" align="left">Price:</td>
                <td align="left"><input type='text' <c:if test="${!empty book}"> value="${book.price}" </c:if> name='bookPrice' id = 'bookPrice' class="validate[required,custom[number]] input_text" title=""/>*</td>
            </tr>
            <tr>
                <td class="label" align="left">Synopsis</td>
                <td align="left"><textarea cols="45" rows="5" name="synopsis" id="synopsis" class="validate[required] input_text" title=""><c:if test="${!empty book}"> ${book.synopsis} </c:if></textarea>*</td>
            </tr>
            <tr>
                <td align="left"></td><td align = "left"><input id='formBookButton' type='submit' class='gb' value='Submit' name='formBookButton' /><input id='cancelBookForm' type='button' class='gb' value='Cancel' name='cancelBookForm' /></td>
            </tr>            
        </table>
        <span class="label">Fields with * are required</span>
        <c:if test="${!empty book}"> <input type="hidden" name="b" id="b" value="${book.productCrypt}"/> </c:if>
        <input type="hidden" name="formType" id="formType" value="${formType}"/>
    </form>
</div>